import android.view.View

//package com.fenghongzhang.module_main.model
//
//
//import android.view.View
//import androidx.lifecycle.MutableLiveData
//import com.fenghongzhang.module_main.R
//import java.io.Serializable
//import java.util.UUID
//import kotlin.random.Random
//
///**
// * 商城相关数据模型
// */
//object MallRowTypes {
//    const val TITLE = 0
//    const val SECKILL_TITLE = 1
//    const val BANNER = 2
//    //第三方服务二手车，跳蚤市场
//    const val THIRD_SERVICE = 22
//    // 热门活动
//    const val ACTIVITY = 3
//
//    // 秒杀&商品
//    const val SECKILL = 4
//    const val GOODS = 5
//
//    // 系列大图
//    const val PIC = 6
//
//    // 系列富文本
//    const val RICH_TXT = 7
//
//    // 推荐商品:最多8个 可以滑动
//    const val RECOMMEND = 8
//
//    // 系列
//    const val SERIES_PIC_BIG = 11// 大图-方图
//    const val SERIES_PIC_SMALL = 12// 一行2个-方图
//    const val SERIES_PIC_RECT = 21// 1行1个-长图
//
//}
//
//object PayChannels {
//    /** 支付宝 */
//    const val ALI = "aliPay"
//
//    /** 微信 */
//    const val WX = "wechat"
//
//    /** 云闪付 */
//    const val UNION_PAY = "cloudFlash"
//
//    /** 云闪付分期 */
//    const val INSTALLMENT = "installment"
//
////    fun takeIcon(channel: String?): Int {
////        return when (channel) {
////            ALI -> R.mipmap.icon_pay_ali
////            WX -> R.mipmap.icon_pay_wx
////            UNION_PAY, INSTALLMENT -> R.mipmap.icon_union_pay
////            else -> R.mipmap.icon_mall_placeholder
////        }
////    }
//}
//
//object PayWays {
//    // 全款
//    const val FULL = "full"
//
//    // 定金
//    const val DEPOSIT = "deposit"
//}
//
//object MallListDisplayMode {
//    const val GRID = 0
//    const val LIST = 1
//}
//
//object MallSeckillStates {
//    // 未开始
//    const val UN_START = 0
//
//    // 进行中
//    const val PROGRESSING = 1
//
//    // 已结束
//    const val FINISHED = 2
//}
//
//object AfterSalesApplyType {
//    // 申请
//    const val APPLY = "APPLY"
//
//    // 撤销申请
//    const val CANCEL = "CANCEL"
//
//    // 再次申请
//    const val RE_APPLY = "RE_APPLY"
//}
//
//object MallRowTags {
//    const val MORE = "MORE"
//    const val ACTIVITY = "ACTIVITY"
//    const val SECKILL = "SECKILL"
//    const val GOODS = "GOODS"
//    const val GOODS_RECOMMEND = "GOODS_RECOMMEND"
//    const val GOODS_PART = "GOODS_PART"
//    const val SECKILL_GOODS = "SECKILL_GOODS"
//    const val BANNER = "BANNER"
//    const val BANNER_BOOKING = "BANNER_BOOKING"
//    const val BANNER_BUY = "BANNER_BUY"
//}
//
//data class MallMotorSeries(
//    var id: Long = 0,
//    var name: String? = null,
//    var pic: String? = RandomPicProvider.pic(),
//    var desc: String? = null,
//    var child: List<MallMotorSeries>? = null,
//    var checked: Boolean = false,
//    var goodsId: Long = 0,
//) : Serializable {
//    fun ifSeries() = !child.isNullOrEmpty()
//
//    private fun formatNameByLength(max: Int): String {
//        val str = name ?: ""
//        val sb = StringBuilder()
//        var index = 0
//
//        for (char in str) {
//            if (index >= max) {
//                sb.append("...")
//                break
//            }
//            when {
//                char.isLetter() -> {
//                    sb.append(char)
//                    if (char.isLowerCase() || char.isUpperCase()) {
//                        index++
//                    } else {
//                        index += 2
//                    }
//                }
//                char.isDigit() -> {
//                    sb.append(char)
//                    index++
//                }
//                else->{
//                    sb.append(char)
//                    index++
//                }
//            }
//        }
//
//        return sb.toString()
//    }
//
//    fun formatLongName(): String {
//        return formatNameByLength(26)
//    }
//
//    fun formatShortName(): String {
//        return formatNameByLength(10)
//    }
//}
//
//data class MallHomeJumpHandler(
//    val tag: String = "",
//    val id: String? = "",
//    val longId: Long = 0,
//    val title: String? = ""
//)
//
//class MallHomeRowItem(
//    var type: Int,
//    var title: String? = null,
//    var id: Long = 0,
//    var tag: String? = null,
//    var banners: List<MallBanner>? = null,
//    var actList: ArrayList<MallActivityItem>? = null,
//    var seckill: SeckillInfo? = null,
//    var goods: MallGoods? = null,
//    var goodsList: ArrayList<MallGoods>? = null,
//    var pic: String? = null,
//    var series: MallMotorSeries? = null,
//    var richText: String? = ""
//) : MultiItemEntity {
//    fun getSpanSize(): Int {
//        return when (type) {
//            MallRowTypes.GOODS, MallRowTypes.SECKILL, MallRowTypes.SERIES_PIC_SMALL -> 1
//            else -> 2
//        }
//    }
//
//    override val itemType: Int
//        get() = type
//}
//
object BannerTypes {
    const val PIC = 0
    const val VIDEO = 1
}
//
class MallBanner(
    var id: Long = 0,
    var dataId: Long? = null,
    var imageUrl: String = "",
    var video: String = "",
    var url: String? = null,
    var name: String? = null,
    var type: String? = null,// 类型{外链out，内部跳转in}
    var displayType: Int = BannerTypes.PIC,
    /**跳转预约试驾时，带车型和code*/
    var modelCode: String? = null,
    var modeName: String? = null,
    var productType: String? = null,
    var adAddr: String? = null,
) {
    fun videoVis(): Int {
        return if (displayType == BannerTypes.VIDEO) View.VISIBLE else View.GONE
    }

    fun placeholderVis(): Int = if (imageUrl.isEmpty() || imageUrl == "empty_img") View.VISIBLE else View.GONE

    fun ifPic(): Boolean {
        return displayType == BannerTypes.PIC
    }

    fun ifVideo(): Boolean {
        return displayType == BannerTypes.VIDEO
    }

    fun jumpNativeGoods(): Boolean = type == "in"

    fun canJumpWeb(): Boolean = type == "out" && !url.isNullOrEmpty()
}

///** 商城-热门活动 */
//class MallActivityItem(
//    var id: Long = 0,
//    var dataId: Long = 0,
//    var name: String,
//    var picUrl: String,
//    var linkUrl: String?,
//    var last: Boolean = false,
//    var isGoods: Boolean = false,
//    var browseTotal: Int = 0,
//    val systemTime: Long = 0,
//    val endTime: Long = 0,
//    val startTime: Long = 0
//) {
//    /** 活动是否已过期 或者 未开始*/
//    fun hasExpired(): Boolean {
//        return endTime in 1 until systemTime || startTime > systemTime
//    }
//
//    fun enableAlpha(): Float = if (hasExpired()) 0.5f else 1f
//
//    fun formatViewCount(): String {
//        if (browseTotal >= 10000) {
//            val w = browseTotal / 10000
//            return "${w}万+"
//        }
//
//        return when {
//            browseTotal > 990000 -> "99万+"
//            browseTotal > 100000 -> "10万+"
//            browseTotal in 10000..99999 -> {
//                val w = browseTotal / 10000
//                "${w}万+"
//            }
//            else -> browseTotal.toString()
//        }
//    }
//}
//
//data class MallActTreeItem(
//    val id: Long = 0,
//    val name: String = "",
//    val parentId: Long = 0,
//    val weight: Int = 0,
//    val children: List<MallActTreeItem>? = null
//)
//
//data class MallActivityDetailItem(
//    val activityDesc: String?,
//    val dataId: Long?,
//    val endTime: String?,
//    val endTimeTimestamp: Long?,
//    val isGoods: Boolean = false,
//    val isTreeMenu: Boolean = false,
//    val join: Boolean = false,
//    val name: String?,
//    val picUrl: String?,
//    val startTime: String?,
//    val startTimeTimestamp: Long = 0,
//    val systemTime: Long = 0
//)
//
//class MallEvaluation(
//    var id: Long = 0,
//    var buyerAvatar: String? = null,
//    var buyerName: String? = null,
//    var star: Float = 1f,
//    var createTime: String? = "",
//    var content: String? = "",
//    var goodsSkuName: String? = "",
//    var buyNum: Int = 0,
//    var isImg: Boolean = false,
//    var sellerContent: String? = "",
//    var buyerResourceList: ArrayList<String>? = null,
//    var videoUrl: String? = null,
//    var last: Boolean = false,
//    var hasShowMore: Boolean = false
//) : MultiItemEntity {
//    override val itemType: Int
//        get() = calcType()
//
//    fun videoCover(): String = "${videoUrl}?x-oss-process=video/snapshot,t_75,m_fast"
//
//    fun buyInfo(): String {
//        return "$goodsSkuName ${buyNum}件"
//    }
//
//    fun moreThan2Pics(): String {
//        val size = buyerResourceList?.size ?: 0
//        return if (size > 2)
//            "+${size - 2}"
//        else ""
//    }
//
//    fun moreThan2PicsVis(): Int {
//        return if (moreThan2Pics().isNullOrEmpty()) View.GONE else View.VISIBLE
//    }
//
//    fun transImgs(max: Int = 0): List<Image>? {
//        val size = buyerResourceList?.size ?: 0
//        val imgList = ArrayList<Image>()
//        buyerResourceList?.forEachIndexed { index, url ->
//            if (url.endsWith(".mp4")) {
//                imgList.add(0, Image(url = url))
//            } else {
//                imgList.add(Image(url = url))
//            }
//        }
//
//        return if (max in 1 until size) {
//            imgList.subList(0, max)
//        } else {
//            imgList
//        }
//    }
//
//    fun formatReplay(): String {
//        return "商家回复：${sellerContent}"
//    }
//
//    private fun calcType(): Int {
//        val hasVideo = !videoUrl.isNullOrEmpty()
//        val picCount = buyerResourceList?.size ?: 0
//        return if (hasVideo) {
//            when (picCount) {
//                0 -> EvaluationListMultiAdapter.TYPE_1V0P
//                1 -> EvaluationListMultiAdapter.TYPE_1V1P
//                else -> EvaluationListMultiAdapter.TYPE_1V2P
//            }
//        } else {
//            when (picCount) {
//                0 -> EvaluationListMultiAdapter.TYPE_0V0P
//                else -> EvaluationListMultiAdapter.TYPE_0V9P
//            }
//        }
//    }
//
//    fun formatNickName(): String {
//        return "${buyerName?.firstOrNull() ?: ""}***${buyerName?.lastOrNull() ?: ""}"
//    }
//
//    fun replayVis(): Int {
//        return if (sellerContent.isNullOrEmpty()) View.GONE else View.VISIBLE
//    }
//
//    fun firstPic(): String {
//        return buyerResourceList?.firstOrNull() ?: ""
//    }
//
//    fun lastPic(): String {
//        return buyerResourceList?.lastOrNull() ?: ""
//    }
//}
//
//fun MallEvaluation.mock(): MallEvaluation {
//    this.id = Random.nextLong(1, Long.MAX_VALUE)
//    this.buyerAvatar = RandomPicProvider.avatar()
//    this.buyerName = RandomNameProvider.getName()
//    this.star = Random.nextInt(2, 11) / 2f
//    this.createTime = "2023-03-15"
//    this.content = RandomNameProvider.random(Random.nextInt(30, 100))
//    this.goodsSkuName = "R1 灰色"
//    this.buyNum = Random.nextInt(1, 10)
//    this.sellerContent = if (Random.nextBoolean() && !BuildConfig.DEBUG) "" else RandomNameProvider.random(Random.nextInt(30, 100))
//    this.buyerResourceList = RandomPicProvider.randomClubAvatarList()
//    this.videoUrl = if (Random.nextBoolean()) "http://2449.vod.myqcloud.com/2449_43b6f696980311e59ed467f22794e792.f20.mp4" else ""
//
//    return this
//}
//
//data class HomeGoodsCategory(
//    val id: Long = 0,
//    val name: String? = "",
//    val details: List<MallGoods>? = null,
//    val mallGoodsInfoPageResponseList: List<MallGoods>? = null,
//) {
//    fun dataList(): List<MallGoods>? {
//        return if (!mallGoodsInfoPageResponseList.isNullOrEmpty())
//            mallGoodsInfoPageResponseList
//        else
//            details
//    }
//}
//
//object ProductTypes {
//    const val VEHICLE = "vehicle"// 整车
//    const val PART = "part"// 配件
//}
//
//data class GoodsAttrOptions(
//    val attrKey: String?,
//    val goodsAttrValues: List<MallGoodsOptions>? = null,
//    val id: Long = 0L,
//    val isShowPic: Boolean = false
//) {
//    fun attrId(): String = "${id}_${attrKey}"
//}
//
//data class MallSkuItem(
//    var attrs: String? = null,
//    var goodsCode: String? = null,
//    var goodsId: Long? = null,
//    val goodsName: String? = null,
//    var goodsTitle: String? = null,
//    val id: Long? = null,
//    val marketPriceFee: Double = 0.0,
//    var purchasePrice: Double = 0.0,
//    val deposit: Double = 0.0,// 定金
//    val referrals: Boolean = false,
//    val saleMessage: String? = null,
//    val saleStatus: Boolean = false,
//    val skuImgUrl: String? = null,
//    val skuImgId: String? = null,
//    val skuName: String? = null,
//    val carCode: String? = null,
//    val longDouStr: String? = null,
//    var stocks: Int = 0,
//    var pointStock: Int = 0,
//    var pointPrice: Int = 0,
//    var pointId: Long = 0,
//    var limitNumber: Int = 1,// 最低购买数
//    var ifDou: Boolean = false,
//    var checked: Boolean = false,
//    var enable: Boolean = true,
//    var last: Boolean = true,
//    var parentGoods: MallGoods? = null,
//    var onEdit: Boolean = false,
//    var priceUp: Boolean = false,
//    var count: Int = 0,// 购买数量
//    var addBySoldOut: Boolean = false
//) {
//    fun sortedIdList(): List<String> = attrs?.split(",")?.sorted() ?: emptyList()
//
//    fun addBtnEnable(): Boolean {
//        val currCount = count
//        return currCount < stocks
//    }
//
//    fun transSkuImgId(): Long? {
//        return if (skuImgId.isNullOrEmpty()) {
//            if (parentGoods != null) {
//                parentGoods?.mainImgId
//            } else null
//        } else skuImgId.toLong()
//    }
//
//    fun requiredSkuImg(): String {
//        return if (skuImgUrl.isNullOrEmpty()) {
//            parentGoods?.mainImgUrl ?: ""
//        } else skuImgUrl
//    }
//
//    fun addCount() {
//        count++
//    }
//
//    fun reduceCount() {
//        count--
//    }
//
//    fun requiredSkuName(): String? {
//        var name = if (skuName.isNullOrEmpty()) {
//            if (goodsTitle.isNullOrEmpty()) {
//                if (goodsName.isNullOrEmpty()) "未知" else goodsName
//            } else goodsTitle
//        } else skuName
//        if (ifDou && pointStock <= 0) {
//            name += "(缺货)"
//        } else if (!ifDou && stocks <= 0) {
//            name += "(售罄)"
//        }
//        return name
//    }
//
//    fun requiredSkuNameOnEmpty(): String? {
//        return if (skuName.isNullOrEmpty()) {
//            if (goodsTitle.isNullOrEmpty()) {
//                // if (goodsName.isNullOrEmpty()) "" else goodsName
//                ""
//            } else goodsTitle
//        } else skuName
//    }
//
//    fun stocksOrPointStocks(): Int {
//        return if (ifDou) pointStock else stocks
//    }
//
//    fun stockInfo(): String {
////        if (stocks <= 0)
////            return "售罄"
//        return "库存 ${stocks.formatCount()}"
//    }
//
//    fun pointStockInfo(): String {
////        if (stocks <= 0)
////            return "售罄"
//        return "库存 ${pointStock.formatCount()}"
//    }
//
//    fun priceInt(): String {
//        return purchasePrice.toInt().toString()
//    }
//
//    fun pointString(): String {
//        return pointPrice.toString()
//    }
//
//    fun formatCrossedPrice(): String {
//        return if (marketPriceFee <= 0) ""
//        else marketPriceFee.formatCNYPrice()
//    }
//
//    fun priceFloat(): String {
//        val ps = purchasePrice.formatDecimal(2)
//        val til = if (priceUp) " 起" else ""
//        return ".${ps.split(".").last()}".replace(".00", "") + til
//    }
//}
//
//data class MallFavoriteGoods(
//    // 收藏相关
//    val marketPriceFee: Double = 0.0,
//    val purchasePrice: Double = 0.0,
//    val goodsId: Long = 0L,
//    val goodsFavoritesId: Long? = null,
//    val goodsFavoritesCode: String? = null,
//    val goodsCode: String? = null,
//    val goodsName: String? = null,
//    val goodsTypeDesc: String? = null,// 物料类型;{vehicle-整车,part-配件}
//    val goodsType: String? = null,// 物料类型;{vehicle-整车,part-配件}
//    val goodsSkuId: Long? = null,
//    val goodsSkuCode: String? = null,
//    val goodsSkuName: String? = null,
//    val mainImageUrl: String? = null,
//    val resourceId: String? = null,
//    var onState: String? = null,// 上架中文状态;{up-上架 down-下架}
//    val onStateDesc: String? = null,// 上架中文状态;{up-上架 down-下架}
//    val monthSales: Int = 0,// 上架中文状态;{up-上架 down-下架}
//    val stock: Int = 0,// 上架中文状态;{up-上架 down-下架}
//    val ifDou: Boolean = false,
//    var onEdit: Boolean = false,
//    var checked: Boolean = false,
//    var last: Boolean = false,
//    var priceUp: Boolean = false,
//) {
//    // 是否已失效
//    fun ifInvalid() = onState != "up"
//
//    fun picAlpha(): Float = if (ifInvalid()) 0.5f else 1f
//
//    fun stockInfo(): String {
//        return "库存 ${stock.formatCount()}"
//    }
//
//    fun soldCount(): String {
//        return if (ifDou) "月兑量 ${monthSales.formatCount()}"
//        else "月销量 ${monthSales.formatCount()}"
//    }
//
//    fun priceInt(): String {
//        return purchasePrice.toInt().toString()
//    }
//
//    fun priceFloat(): String {
//        val ps = purchasePrice.formatDecimal(2)
//        val til = if (priceUp) " 起" else ""
//        return ".${ps.split(".").last()}".replace(".00", "") + til
//    }
//
//    fun formatCrossedPrice(): String {
//        return if (marketPriceFee <= 0) ""
//        else marketPriceFee.formatCNYPrice()
//    }
//}
//
//data class ShoppingCartResp(
//    val screen: List<ShoppingCartScreen>? = null,
//    val shoppingCartDtos: ArrayList<ShoppingCartItem>? = null
//) : BaseOpenApiModel()
//
//data class ShoppingCartScreen(
//    val categoryId: Long = 0L,
//    val number: Int = 0,
//    val categoryCode: String? = null,
//    val categoryName: String? = null,
//    var checked: Boolean = false
//)
//
//data class ShoppingCartItem(
//    val goodsSkuId: Long? = 0L,
//    val categoryId: Long? = 0L,
//    val goodsId: Long = 0L,
//    val resourceId: Long? = 0L,
//
//    val categoryCode: String? = null,
//    val carCode: String? = null,
//    val categoryName: String? = null,
//    val goodsSkuCode: String? = null,
//    val goodsCode: String? = null,
//    val goodsSkuName: String? = null,
//    val goodsName: String? = null,
//    var onState: String? = null,// 上架状态;{up-上架 down-下架}
//    val onStateDesc: String? = null,// 上架状态;{up-上架 down-下架}
//    val mainImageUrl: String? = null,// 上架状态;{up-上架 down-下架}
//
//    var number: Int = 0,
//    var stocks: Int = 0,
//    val specInvalid: Boolean = false,
//    val isMoreSku: Boolean = false,// 是否有其他sku
//    val priceUp: Boolean = false,// 是否有其他sku
//
//    val price: Double = 0.0,
//    var totalPrice: Double = 0.0,
//
//    var onEdit: Boolean = false,
//    var checked: Boolean = false,
//    var checkAble: Boolean = true,
//    var last: Boolean = false,
//    var ifDou: Boolean = false,
//    var longDouStr: String? = ""
//) : Cloneable {
//    public override fun clone(): Any {
//        return super.clone()
//    }
//
//    fun subStrSkuName(): String {
//        val max = 24
//        val str = goodsSkuName ?: ""
//        val sb = StringBuilder()
//        var index = 0
//
//        for (char in str) {
//            if (index >= max) {
//                sb.append("...")
//                break
//            }
//            when {
//                char.isLetter() -> {
//                    sb.append(char)
//                    if (char.isLowerCase() || char.isUpperCase()) {
//                        index++
//                    } else {
//                        index += 2
//                    }
//                }
//                char.isDigit() -> {
//                    sb.append(char)
//                    index++
//                }
//                else->{
//                    sb.append(char)
//                    index++
//                }
//            }
//        }
//
//        return sb.toString()
//    }
//
//    fun addCount() {
//        number++
//    }
//
//    fun reduceCount() {
//        number--
//    }
//
//    fun transSkuName(): String {
//        goodsSkuName?.apply {
//            return if (this.length > 16) {
//                "${this.substring(0, 14)}..."
//            } else this
//        }
//        return ""
//    }
//
//    fun makeSkuItem(): MallSkuItem {
//        return MallSkuItem(
//            id = goodsSkuId,
//            skuName = goodsSkuName,
//            goodsCode = goodsSkuCode,
//            goodsId = goodsId,
//            goodsName = goodsName,
//            parentGoods = MallGoods(id = goodsId, code = goodsCode, title = goodsName),
//            count = number,
//            skuImgUrl = mainImageUrl,
//            skuImgId = resourceId?.toString()
//        )
//    }
//
//    fun addAble(): Boolean = number < stocks
//    fun reduceAble(): Boolean = number > 1
//
//    fun updateTotalPrice() {
//        totalPrice = price * number
//    }
//
//    fun moreArrowVis(): Int = if (isMoreSku) View.VISIBLE else View.GONE
//
//    fun picAlpha(): Float = if (ifSpecInvalid()) 0.5f else 1.0f
//
//    fun hasStocks(): Boolean = stocks > 0
//
//    fun ifSpecInvalid(): Boolean = specInvalid || onState == "down"
//
//    fun tips(): String = if (ifSpecInvalid()) "商品已失效，不可购买" else "请重新选择规格"
//
//    fun canBuy(): Boolean = !ifSpecInvalid() && hasStocks()
//
//    fun priceInt(): String {
//        return price.toInt().toString()
//    }
//
//    fun priceFloat(): String {
//        val ps = price.formatDecimal(2)
//        val til = if (priceUp) " 起" else ""
//        return ".${ps.split(".").last()}".replace(".00", "") + til
//    }
//}
//
//data class MallSeckillCodeItem(
//    val code: String = "",
//    val num: Int = 0,
//    val createOrder: Boolean = false
//)
//
//class MallSeckillGoods(
//    val seckillSurplusNum: Int = 0,
//    val skillId: Long = 0L
//) : MallGoods() {
//    fun seckillStockInfo(): String {
//        return "库存 $seckillSurplusNum"
//    }
//
//    // 秒杀商品不支持定金
//    override fun ifSupportDeposit(): Boolean {
//        return false
//    }
//
//    fun makeSkuList(): List<MallSkuItem> {
//        val sku = skuList?.first() ?: MallSkuItem()
//        sku.stocks = seckillSurplusNum
//        sku.purchasePrice = purchasePrice
//        sku.count = 1
//        return listOf(sku)
//    }
//}
//
//data class OneMoreMallGoods(
//    val brandCode: String = "",
//    val brandName: String = "",
//    val categoryCode: String = "",
//    val categoryName: String = "",
//    val goodsCode: String = "",
//    val goodsId: Long = 0,
//    val goodsName: String = "",
//    val goodsSkuCode: String = "",
//    val goodsSkuId: Long = 0,
//    val goodsSkuName: String = "",
//    val mainImageUrl: String = "",
//    val number: Int = 0,
//    val price: Double = 0.0,
//    val remark: String = "",
//    val resourceId: Long = 0
//)
//
//open class MallGoods(
//    var id: Long = 0L,
//    val goodsId: Long = 0,
//    val mainImgId: Long = 0,
//    var mainImgUrl: String? = null,
//    var picUrl: String? = null,
//    var goodsMainPhoto: String? = null,
//    // 划线价
//    var marketPriceFee: Double = 0.0,
//    var purchasePrice: Double = 0.0,
//    var price: Double = 0.0,// 龙豆划线价
//    var deposit: Double = 0.0,// 定金
//    var title: String? = null,
//    val skuId: Long = 0,
//    val skuName: String? = null,
//    var soldNum: Long = 0,// 月销量
//    var monthSalesNum: Long = 0,// 月销量
//    var stocks: Int = 0,// 库存
//    var productType: String? = "",// 商品类型
//    // 详情相关
//    val brandName: String? = null,
//    val code: String? = null,
//    val detailUrl: List<String>? = null,
//    val videoUrl: List<String>? = null,
//    val skuList: List<MallSkuItem>? = null,
//    val skuItem: MallSkuItem? = null,
//    val specAttrList: List<GoodsAttrOptions>? = null,
//    val details: String? = null,
//    val params: String? = null,
//    val posterUll: List<String>? = null,
//    val tlineCode: String? = null,
//    val tlineName: String? = null,
//    val videoImgUrl: String? = null,
//    var desc: String? = null,
//    var longDou: Int = 0,
//    var count: Int = 1,
//    val discount: Int = 0,
//    var displayType: Int = MallListDisplayMode.GRID,
//    var stateName: String? = "",
//    val post: Boolean = false,// 是否包邮
//    val ifVirtual: Boolean = false,// 是否是虚拟商品
//    var onEdit: Boolean = false,
//    var checked: Boolean = false,
//    var last: Boolean = false,
//    var ifDou: Boolean = false,
//    var ifSeckill: Boolean = false,
//    var isVirtually: Boolean = false,
//    var priceUp: Boolean = false,// 多规格且价格不同的需要展示起
//    var point: String? = null,// 龙豆
//    /**埋点数据*/
//    var model: String? = "",
//    var brandId: String? = "",
//    var modelCode: String? = "",
//    var modelName: String? = "",
//) : MultiItemEntity {
//    fun pointTail(): String {
//        return if (priceUp || multiSkuPoint()) " 起" else ""
//    }
//
//    /** 是否是虚拟商品 */
//    fun ifVirtual(): Boolean {
//        return isVirtually
//    }
//
//    fun postTips(): String = if (post) "包邮" else "不包邮"
//
//    fun flagName(): String {
//        return if (marketPriceFee <= 0) "秒杀" else "${discount}折"
//    }
//
//    fun crossedPriceVis(): Int = if (marketPriceFee <= 0) View.GONE else View.VISIBLE
//
//    fun formatPrice(): String {
//        return purchasePrice.formatCNYPrice()
//    }
//
//    fun formatDepositPrice(): String {
//        return if (deposit == 0.0)
//            (purchasePrice * 0.2).formatCNYPrice()
//        else deposit.formatCNYPrice()
//    }
//
//    fun soldOutBtnText(): String = if (ifDou) "已兑完" else "已售罄"
//    fun soldOutBtnVis(): Int = if (calcRealStocks() <= 0) View.VISIBLE else View.GONE
//    fun buyNowSingleBtnVis(): Int = if (calcRealStocks() > 0 && ifVehicle() && !ifDou) View.VISIBLE else View.GONE
//    fun buyNowBtnVis(): Int = if (calcRealStocks() > 0 && !ifVehicle() && !ifDou) View.VISIBLE else View.GONE
//    fun addCartBtnVis(): Int = if (calcRealStocks() > 0 && !ifVehicle() && !ifDou) View.VISIBLE else View.GONE
//
//    // 龙豆相关按钮
//    fun exchangeBtnVis(): Int = if (calcRealStocks() > 0 && ifDou) View.VISIBLE else View.GONE
//
//    // 是否是整车
//    fun ifVehicle() = productType == ProductTypes.VEHICLE
//
//    // 是否是配件
//    fun ifPart() = productType == ProductTypes.PART
//
//    fun needCalcExpressFee(): Boolean = !ifVehicle() && !post
//
//    // 是否支持定金
//    open fun ifSupportDeposit(): Boolean {
//        // 整车&定金>0
//        return ifVehicle() && (skuList?.firstOrNull()?.deposit ?: 0.0) > 0
//    }
//
//    fun addCartVis(): Int {
//        return if (ifDou || ifVehicle()) View.GONE else View.VISIBLE
//    }
//
//    fun yellowState(): String {
//        return when (Random.nextInt(10)) {
//            1 -> "剩余支付时间：29分55秒"
//            7 -> "退款成功"
//            else -> ""
//        }
//    }
//
//    fun longDouStr(): String {
//        return longDou.toString()
//    }
//
//    fun priceInt(): String {
//        return purchasePrice.toInt().toString()
//    }
//
//    fun priceFloat(): String {
//        val ps = purchasePrice.formatDecimal(2)
//        val til = if (priceUp || multiSkuPrice()) " 起" else ""
//        return ".${ps.split(".").last()}".replace(".00", "") + til
//    }
//
//    private fun multiSkuPrice(): Boolean {
//        val priceSet = skuList?.map { it.purchasePrice }?.toHashSet()
//        return priceSet != null && priceSet.size > 1
//    }
//
//    private fun multiSkuPoint(): Boolean {
//        val priceSet = skuList?.map { it.pointPrice }?.toHashSet()
//        return priceSet != null && priceSet.size > 1
//    }
//
//    fun formatCrossedPrice(): String {
//        return if (ifDou) {
//            if (price > 0) price.formatCNYPrice()
//            else ""
//        } else if (marketPriceFee <= 0) ""
//        else marketPriceFee.formatCNYPrice()
//    }
//
//    fun formatSeckillCrossedPrice(): String {
//        return if (marketPriceFee <= 0) ""
//        else "原价：${marketPriceFee.formatCNYPrice()}"
//    }
//
//    fun descVis(): Int {
//        return if (desc.isNullOrEmpty()) View.GONE else View.VISIBLE
//    }
//
//    fun modeInfo(): String {
//        return "亚黑 透明 M，升级款"
//    }
//
//    fun countInfo(): String {
//        return "x${count}"
//    }
//
//    fun stateVis() = if (stateName.isNullOrEmpty()) View.GONE else View.VISIBLE
//
//    /** 计算总库存 */
//    fun calcRealStocks(): Int {
//        var realStock = if (ifDou) skuList?.sumOf { it.pointStock } ?: 0 else skuList?.sumOf { it.stocks } ?: 0
//        if (realStock <= 0)
//            realStock = stocks
//        return realStock
//    }
//
//    fun stockInfo(): String {
//        val realStock = calcRealStocks()
////        if (realStock <= 0)
////            return "售罄"
//        return "库存 ${realStock.formatCount()}"
//    }
//
//    fun soldCount(): String {
//        return if (ifDou) "月兑量 ${monthSalesNum.formatCount()}"
//        else "月销量 ${soldNum.formatCount()}"
//    }
//
//    fun stockCount(state: Int): String {
//        if (stocks <= 0)
//            return ""
//        return if (state == MallSeckillStates.UN_START) "共${stocks}件" else "仅剩余${stocks}件"
//    }
//
//    fun buyBtnVis(state: Int): Int = if (state == 1 && stocks > 0) View.VISIBLE else View.GONE
//
//    fun soldOutBtnVis(state: Int): Int = if (state == 1 && stocks <= 0) View.VISIBLE else View.GONE
//
//    fun secKillName(): String {
//        // return "\u3000 \u3000${title}"
//        return title ?: ""
//    }
//
//    override val itemType: Int
//        get() = displayType
//}
//
//data class RecentlyPurchased(
//    val message: String? = "",
//    val userName: String? = "",
//    val mainImageUrl: String? = "",
//)
//
//class MallAddressItem(
////    var userId: Long? = null,
//    var id: Long? = null,
//    var receiverName: String? = null,
//    var receiverPhone: String? = null,
//    var receiverAddress: String? = null,
//    var address: String? = null,
//    var provinceName: String? = null,
//    var provinceCode: String? = null,
//    var cityName: String? = null,
//    var cityCode: String? = null,
//    var districtName: String? = null,
//    var districtCode: String? = null,
//    var postalCode: String? = null,
//    var status: String? = null,
//    var remark: String? = null,
//    var checked: Boolean = false,
//    var isDefault: Boolean = false,
//    var streetCode: String? = null,
//    var streetName: String? = null,
//) : BaseBody() {
//    fun formatAddress(): String {
//        return "${provinceName ?: ""}${cityName ?: ""}${districtName ?: ""}${address ?: ""}"
//    }
//
//    fun requiredName(): String {
//        receiverName?.let {
//            if (it.length > 7) {
//                return "${receiverName?.substring(0, 6)}.."
//            }
//        }
//        return receiverName ?: ""
//    }
//
//    fun namePhone(): String {
//        receiverName?.let {
//            if (it.length > 7) {
//                return "${receiverName?.substring(0, 6)}..  ${receiverPhone?.desensitization()}"
//            }
//        }
//        return "$receiverName  ${receiverPhone?.desensitization()}"
//    }
//
//    fun areaName(): String {
//        return "${provinceName ?: ""} ${cityName ?: ""} ${districtName ?: ""}".trim()
//    }
//
////    fun mock(): MallAddressItem {
////        this.receiverName = RandomNameProvider.getName()
////        this.receiverPhone = Random.phoneNumber()
////        this.address = "天府大道中段环球中心海洋馆"
////        this.postalCode = Random.nextInt(100000, 999999).toString()
////        return this
////    }
//}
//
//data class MallSearchItem(
//    val id: Long = 0,
//    val name: String,
//    val type: Int = 0
//)
//
//data class MallMotorBrandItem(
//    val id: Long = 0,
//    val code: String? = null,
//    val name: String? = null,
//    val dictName: String? = null,
//    val dictKey: String? = null,
//    var checked: Boolean = false
//) {
//    fun requiredBrandName(): String {
//        return if (!name.isNullOrEmpty()) name else if (!dictName.isNullOrEmpty()) dictName else ""
//    }
//}
//
//data class MallGoodsOptions(
//    val attrKeyId: Long = 0L,
//    val id: Long = Random.nextLong(1, Long.MAX_VALUE),
//    val attrValue: String? = null,
//    val fileUrl: String? = null,
//    var type: Int = 0,
//    var checked: Boolean = false,
//    var enable: Boolean = true,
//    var ifDou: Boolean = true,
//    var totalStocks: Int = 0,// 当前规格在所有选项里面的总库存
//    var soldOutIds: ArrayList<String> = ArrayList(),
//    var allSoldOut: Boolean = false
//) {
//    fun formatAttrVal(): String? {
//        val tail = if (ifDou) "缺货" else "售罄"
//        return if (enable) attrValue else "${attrValue}(${tail})"
//    }
//}
//
//data class GoodsOrSkuItem(
//    var goods: MallGoods,
//    var sku: MallSkuItem? = null,
//    var ifDou: Boolean = false
//) {
//    fun formatGoodsCountStr(): String {
//        return if (goods.count <= 0) "" else goods.count.toString()
//    }
//
//    fun priceInt(): String = sku?.priceInt() ?: goods.priceInt()
//
//    fun priceFloat(): String = sku?.priceFloat() ?: goods.priceFloat()
//
//    /** 确保购买数量不超过sku库存 */
//    fun checkStockCount() {
//        val currCount = goods.count
//        sku?.let {
//            val takeStocks = if (ifDou) it.pointStock else it.stocks
//            if (currCount == 0 && takeStocks > 0)
//                goods.count = 1
//            else if (currCount > takeStocks) {
//                goods.count = takeStocks
//            }
//            if (goods.count < 0)
//                goods.count = 0
//        }
//    }
//
//    fun pointString(): String {
//        return sku?.pointPrice?.toString() ?: goods.point ?: "0"
//    }
//
//    fun bottomBtnEnable(): Boolean {
//        return sku != null && goods.count > 0
//    }
//
//    fun mainImgUrl(): String {
//        val skuImg = sku?.skuImgUrl
//        return if (skuImg.isNullOrEmpty())
//            goods.mainImgUrl ?: ""
//        else skuImg
//    }
//
//    fun addBtnEnable(): Boolean {
//        val currCount = goods.count
//        if (sku != null) {
//            return if (ifDou) currCount < sku!!.pointStock else currCount < sku!!.stocks
//        }
//        return currCount < goods.stocks
//    }
//
//    fun reduceBtnEnable(): Boolean {
//        return goods.count > 1
//    }
//
//    fun stocksCount(): Int {
//        return if (sku != null) {
//            if (ifDou) sku!!.pointStock else sku!!.stocks
//        } else goods.stocks
//    }
//
//    fun stockInfo(): String {
//        return if (ifDou) {
//            sku?.pointStockInfo() ?: goods.stockInfo()
//        } else {
//            sku?.stockInfo() ?: goods.stockInfo()
//        }
//    }
//
//    fun code(): String {
//        val code = sku?.goodsCode ?: goods.code
//        if (code.isNullOrEmpty())
//            return ""
//        return "编号：${code}"
//    }
//}
//
//class MallGoodsChooseOptions(
//    var color: MallGoodsOptions? = null,
//    var size: MallGoodsOptions? = null,
//    var skuItem: MallSkuItem? = null,
//    val map: HashMap<String, MallGoodsOptions?> = HashMap(),
//    var count: Int = 0
//) {
//    fun makeInfo(): String {
//        // return "${color?.attrValue ?: ""}，${size?.attrValue ?: ""}，${count}件".replace("，，", "")
//        return if (skuItem != null) "${skuItem?.requiredSkuName() ?: ""}，${count}件" else "请选择"
//    }
//}
//
//data class MallSeckillItem(
//    val id: Long = 0,
//    val goodsId: Long = 0,
//    val mainImgId: Long = 0,
//    val mainImgUrl: String = "",
//    val marketPriceFee: Double = 0.0,
//    val purchasePrice: Double = 0.0,
//    val skuId: Long = 0,
//    val skuName: String = "",
//    val soldNum: String = "",
//    val stocks: Int = 0,
//    val title: String = ""
//)
//
//open class BaseMallResponse {
//    var code: String? = null
//    var context: String? = null
//    var detail: String? = null
//    var message: String? = null
//    var partnerId: Long = 0
//    var requestNo: String? = null
//    var service: String? = null
//    var success: Boolean? = null
//    var version: String? = null
//}
//
//class GoodsFormInfoItem(
//    var id: String? = "",
//    var key: String = "",
//    var value: String = "",
//    var first: Boolean = false,
//    var last: Boolean = false,
//    var showArrow: Boolean = false
//) {
//
//}
//
//data class MallOrderDetailResp(
//    val unitPrice: Double?,
//    var orderDetailCode: String? = null,// 订单详情编码
//    var mainImageUrl: String? = null,// 封面图链接
//    var resourceId: Long? = null,// 资源文件id
//    var goodsId: Long? = null,
//    var goodsCode: String? = null,
//    var goodsName: String? = null,
//    var goodsSkuId: String? = null,
//    var goodsSkuName: String? = null,
//    var goodsSkuCode: String? = null,
//    var afterSalesType: String? = null,// 售后处理类型(exchange-换货，return-退货，refund-退款)(售后订单没有该值)
//    var afterSalesTypeDesc: String? = null,// 售后处理类型(exchange-换货，return-退货，refund-退款)(售后订单没有该值)
//    var afterSalesStatusDesc: String? = null,// afterSalesType + afterSalesAuditStatus 中文组合(售后订单没有该值)
//    var afterSalesAuditStatus: String? = null,// 后台售后审批进度状态(success-成功，fail-失败，processing-处理中 2字段拼接再一起组合展示)(售后订单没有该值)
//    var afterSalesDetailCode: String? = null,// 详情对应售后详情code
//    var storeInstall: Boolean = false,// 门店安装
//    var isAfterSales: Boolean = false,// 是否已申请售后
//    var price: Double = 0.0,
//    var number: Int = 0,
//    var surplusPayTime: Long = 0L,// 剩余支付时间
//    // 自定义
//    var checked: Boolean = false,// 是否已选
//    var priceUp: Boolean = false,// 是否有起
//    var onEdit: Boolean = false,// 是否编辑状态
//    // 商品评论时使用
//    var rating: Float = 0f,
//    var evaluationContent: String? = null,
//    var vouchers: List<Long>? = null,// 上传凭证
//    var ifDou: Boolean = false,
//    var ifVirtual: Boolean = false,
//) {
//    fun ifDouGoods() = ifDou && !ifVirtual
//
//    fun formatRatingStr(): String {
//        return when (rating) {
//            1f -> "非常差"
//            2f -> "差"
//            3f -> "一般"
//            4f -> "满意"
//            5f -> "非常满意"
//            else -> ""
//        }
//    }
//
//    fun formatPointPrice(): String {
//        return price.toInt().toString()
//    }
//
//    fun stateVis(): Int {
//        // return if (isAfterSales) View.VISIBLE else View.GONE
//        return if (afterSalesStatusDesc.isNullOrEmpty()) View.GONE else View.VISIBLE
//    }
//
//    fun stateName(): String {
//        return afterSalesStatusDesc ?: ""
//    }
//
//    fun priceInt(): String {
//        return if (unitPrice != null && unitPrice > 0)
//            unitPrice.toInt().toString()
//        else price.toInt().toString()
//    }
//
//    fun priceFloat(): String {
//        val ps = if (unitPrice != null && unitPrice > 0)
//            unitPrice.formatDecimal(2)
//        else
//            price.formatDecimal(2)
//
//        val til = if (priceUp) " 起" else ""
//        return ".${ps.split(".").last()}".replace(".00", "") + til
//    }
//
//    fun countInfo(): String = "x${number}"
//
//    fun yellowState(): String {
//        if (surplusPayTime <= 0) {
//            return ""
//        }
//        val sec = surplusPayTime / 1000
//        val h = sec / 3600
//        val m = sec / 60 % 60
//        val s = sec % 60
//        val hh = if (h > 0) "${h.formatTimeTwo()}小时" else ""
//        val mm = "${m.formatTimeTwo()}分"
//        val ss = "${s.formatTimeTwo()}秒"
//
//        return "剩余支付时间：${hh}${mm}${ss}"
//    }
//}
//
//data class MallAfterOrderItem(
//    val afterSalesType: String?,
//    val afterSalesTypeDesc: String?,
//    val detailResponses: List<MallOrderDetailResp>?,
//    val originOrderCode: String?,
//    val progress: String?,
//    val progressStatus: String?,
//    val refundPrice: Double?,
//    val serviceCode: String?,
//    val status: String?,
//    val statusDesc: String?,
//    val originOrderStatus: String?,
//    val couponCode: String?,
//    val againFlag: Boolean = false,
//    val retreatFlag: Boolean = false,
//    val expressFlag: Boolean = false,
//) {
//    fun tag(): String = if (afterSalesType == "refund") "退款" else "售后"
//    fun formatProgress1(): String = progressStatus ?: ""
//    fun formatProgress2(): String = progress ?: ""
//    fun formatOrderNo4After(): String {
//        return "服务编号：${serviceCode}"
//    }
//
//    fun goodsCount(): String {
//        val skuCount = detailResponses?.sumOf { it.number }
//        return "共${skuCount}件商品，总计："
//    }
//
//    fun ifClose(): Boolean = "close" == status
//
//    // 再次申请-按钮是否可见
//    fun againBtnVis() = if (againFlag) View.VISIBLE else View.GONE
//
//    // 撤销申请-按钮是否可见
//    fun retreatBtnVis() = if (retreatFlag) View.VISIBLE else View.GONE
//
//    // 填写单号-按钮是否可见
//    fun expressBtnVis() = if (expressFlag) View.VISIBLE else View.GONE
//}
//
//data class PayChannelItem(
//    val payChannel: String? = "",// 订单付款方式
//    val payChannelDesc: String? = "",// 订单付款方式
//    var checked: Boolean = false,
//    var last: Boolean = false,
//)
//
//class MallOrderItem(
//    val id: Long = 0,// 订单ID
//    val buyerId: Long = 0,// 订单ID
//    val couponId: Long = 0,// 订单ID
//    val orderCode: String? = "",// 订单号
//    val buyerCode: String? = "",// 订单号
//    val buyerName: String? = "",// 订单号
//    val couponCode: String? = "",// 订单号
//    val couponName: String? = "",// 订单号
//    val payNo: String? = "",// 支付单号
//    val payOrderNo: String? = "",// 支付单号
//    val payWay: String? = "",// 付款方式（full-全款支付，deposit-定金）返回英文标识，一般整车才有
//    val payWayDesc: String? = "",// 订单付款方式
//    val payChannel: String? = "",// 订单付款方式
//    val payChannelDesc: String? = "",// 订单付款方式
//    val expressCode: String? = "",// 订单付款方式
//    val payTime: String? = "",// 支付时间
//    val createTime: String? = "",// 创建时间
//    val status: String? = "",
//    val statusDesc: String? = "",// 订单状态
//    val createOrderTime: String? = "",// 下单时间
//    val closeOrderTime: String? = "",// 交易关闭时间
//    val payOrderTime: String? = "",// 订单支付时间
//    val deliveryTime: String? = "",// 发货时间
//    val deliveryInfos: List<DeliveryInfo>? = null,// 发货单列表
//    val finishTime: String? = "",// 订单完成时间
//    val cartTime: String? = "",// 整车-提车时间
//    val remark: String? = "",// 备注
//    val orderType: String? = "",// 订单类型返回英文标识（vehicle-整车，part-配件）
//    val orderTypeDesc: String? = "",// 订单类型返回英文标识（vehicle-整车，part-配件）
//    val pointGoodsType: String? = "",// virtual - 虚拟  goods-实物
//    val pointGoodsTypeDesc: String? = "",//virtual - 虚拟  goods-实物
//    val servicePhone: String? = "",// 售后服务电话
//    val amountPaid: Double = 0.0,// 订单应付金额
//    val originalPrice: Double = 0.0,// 订单原价
//    val discountPrice: Double = 0.0,// 订单优惠金额
//    val profitPrice: Double = 0.0,// 手续费金额
//    val balanceDue: Double = 0.0,// 订单结欠金额
//    val depositPrice: Double = 0.0,// 定金金额
//    val goodsTotalNum: Int = 0,// 商品总数
//    val douAmount: Int = 0,// 龙豆
//    val point: Int = 0,// 奖励龙豆
//    val goodsList: List<MallGoods>? = null,
//    val goods: MallGoods? = null,
//    val skuList: List<MallSkuItem>? = null,
//    val cartList: List<ShoppingCartItem>? = null,
//    var ifDou: Boolean = false,
//    var priceUp: Boolean = false,
//    val expressFee: Double = 0.0,// 运费
//    val surplusPayTime: Long = 0L,// 剩余支付时间
//    // 状态Bool字段
//    var goReceive: Boolean = false,// 是否可以去收货
//    var goEvaluate: Boolean = false,// 是否可以去评价
//    var oneMoreFlag: Boolean = false,// 再来一单
//    var isDelivery: Boolean = false,// 是否存在发货单
//    var applyAfterSale: Boolean = false,// 是否可以申请售后
//    var applyRefund: Boolean = false,// 是否可以申请退款
//    var detailResponses: ArrayList<MallOrderDetailResp>? = null// 订单详情
//) {
//    fun ifVehicle(): Boolean {
//        return orderType == "vehicle"
//    }
//
//    // 龙豆商品-实物
//    fun ifPointGoods(): Boolean = pointGoodsType == "goods"
//
//    // 龙豆商品-虚拟
//    fun ifPointVirtual(): Boolean = pointGoodsType == "virtual"
//
//    // 各种按钮显示还是隐藏
//    fun payBtnVis(): Int = if (status == MallOrderState.UNPAID) View.VISIBLE else View.GONE
//    fun expressBtnVis(): Int = if (isDelivery) View.VISIBLE else View.GONE
//    fun receiveBtnVis(): Int = if (goReceive) View.VISIBLE else View.GONE
//    fun evaluateBtnVis(): Int = if (goEvaluate) View.VISIBLE else View.GONE
//    fun oneMoreBtnVis(): Int = if (oneMoreFlag) View.VISIBLE else View.GONE
//    fun afterSalesBtnVis(): Int = if (applyAfterSale) View.VISIBLE else View.GONE
//    fun refundBtnVis(): Int = if (applyRefund) View.VISIBLE else View.GONE
//
//    fun formatPayChannelTitle(): String {
//        return "${payChannelDesc}交易号"
////        return when (payChannel) {
////            "aliPay" -> "支付宝交易号"
////            "wechat" -> "微信交易号"
////            else -> ""
////        }
//    }
//
//    /** 判断该订单是否使用了优惠券 */
//    fun hasUseCoupon(): Boolean {
//        return !couponCode.isNullOrEmpty()
//        // 活动价也是discountPrice 所以不能用discountPrice判断
////                || discountPrice > 0
//    }
//
//    fun takeGoodsPrice(payWay: String = PayWays.FULL, disAmount: Double = 0.0, expFee: Double = 0.0, costTrial: Double): MallGoods {
//        val totalAmount = if (payWay == PayWays.FULL) {
//            skuList?.sumOf { it.purchasePrice * it.count }
//        } else {
//            skuList?.sumOf { it.deposit * it.count }
//        } ?: 0.0
//        val tempGoods = MallGoods()
//        tempGoods.purchasePrice = totalAmount - disAmount + expFee + costTrial
//
//        return tempGoods
//    }
//
//    fun takeExpressPrice(): MallGoods {
//        return MallGoods(purchasePrice = expressFee)
//    }
//
//    fun formatOrderNo(): String {
//        return "订单号：${orderCode}"
//    }
//
//    fun goodsCount(): String {
//        val skuCount = detailResponses?.sumOf { it.number }
//        return "共${skuCount}件商品，总计："
//    }
//
//    fun stateName(): String {
//        return if (!statusDesc.isNullOrEmpty()) statusDesc else MallOrderState.STATE_NAMES[status] ?: "未知状态"
//    }
//
//    fun priceInt(): String {
//        return amountPaid.toInt().toString()
//    }
//
//    fun formatPointPrice(): String {
//        return originalPrice.toInt().toString()
//    }
//
//    fun priceFloat(): String {
//        val ps = amountPaid.formatDecimal(2)
//        val til = if (priceUp) " 起" else ""
//        return ".${ps.split(".").last()}".replace(".00", "") + til
//    }
//
//    fun btnLayoutVis4Mall(): Int {
//        return when (View.VISIBLE) {
//            payBtnVis() -> View.VISIBLE
//            expressBtnVis() -> View.VISIBLE
//            receiveBtnVis() -> View.VISIBLE
//            evaluateBtnVis() -> View.VISIBLE
//            oneMoreBtnVis() -> View.VISIBLE
//            afterSalesBtnVis() -> View.VISIBLE
//            refundBtnVis() -> View.VISIBLE
//            else -> View.GONE
//        }
//    }
//
//    fun btnLayoutVis4Dou(): Int {
//        return if (btnExpressBtnVis4Dou() * redBtnVis4Dou() == 0) View.VISIBLE else View.GONE
//    }
//
//    fun btnExpressBtnVis4Dou(): Int {
//        val ifVirtual = (goodsList?.find { it.ifVirtual }) != null
//        // 虚拟商品没有物流信息
//        return if (!ifVirtual && status in listOf(
//                MallOrderState.WAIT_RECEIVE,
//                MallOrderState.TO_BE_EVALUATED,
//                MallOrderState.FINISHED,
//            )
//        ) View.VISIBLE else View.GONE
//    }
//
//    fun redBtnVis4Dou(): Int {
//        return if (status in listOf(
//                MallOrderState.WAIT_RECEIVE,
//                MallOrderState.TO_BE_EVALUATED
//            )
//        ) View.VISIBLE else View.GONE
//    }
//
//    fun redBtnTxt4Dou(): String {
//        return when (status) {
//            MallOrderState.WAIT_RECEIVE -> "确认收货"
//            MallOrderState.TO_BE_EVALUATED -> "评价"
//            else -> ""
//        }
//    }
//}
//
//object MallActState {
//    const val NEW = "new"
//    const val HOT = "hot"
//}
//
//object MallOrderState {
//    const val ALL = "all"
//    const val UNPAID = "unpaid"
//    const val TO_BE_DELIVERED = "toBeDelivered"
//    const val WAIT_RECEIVE = "waitReceive"
//    const val TO_BE_EVALUATED = "toBeEvaluated"
//    const val FINISHED = "finish"
//    const val CLOSED = "close"
//    const val SUCCESS = "success"
//    const val TO_BE_CART = "toBeCart"
//
//    const val PAID = "_paid"
//    const val CANCELED = "_canceled"
//    const val REFUND = "_refund"
//    const val AFTER_SALES = "AFTER_SALES"
//
//    val STATE_LIST = listOf(
//        ALL, UNPAID, TO_BE_DELIVERED, WAIT_RECEIVE, TO_BE_EVALUATED,
//        FINISHED, SUCCESS, TO_BE_CART, PAID, CANCELED, REFUND, AFTER_SALES
//    )
//
//    val STATE_NAMES: HashMap<String, String> = hashMapOf(
//        ALL to "全部",
//        UNPAID to "待支付",
//        PAID to "已支付",
//        CANCELED to "已取消",
//        CLOSED to "交易关闭",
//        TO_BE_DELIVERED to "待发货",
//        WAIT_RECEIVE to "待收货",
//        REFUND to "已退款",
//        TO_BE_EVALUATED to "待评价",
//        FINISHED to "交易成功",
//        TO_BE_CART to "待提车",
//        CLOSED to "交易关闭",
//        AFTER_SALES to "退款/售后"
//    )
//}
//
//class MallHomeLiveData {
//    var showHome = MutableLiveData(false)
//}
//
//class MallEditorLiveData {
//    var ifEdit = MutableLiveData(false)// 是否处于编辑模式
//    var fullCount = 0// 全部数量 = 可用的+不可用的
//    var totalCount = MutableLiveData(0)// 总数多少 = 可用的
//    var checkedCount = MutableLiveData(0)// 已选多少
//    var skuNumber = MutableLiveData(0)// sku的总数
//    var totalPrice = MutableLiveData(0.0)// 总价
//    var originalPrice = MutableLiveData(0.0)// 原价
//    var disAmount = MutableLiveData(0.0)// 总优惠
//    var tabIndex = MutableLiveData(0)
//
//    fun bottomContainerVis(): Int {
//        return if (ifEdit.value == true && fullCount == 0) View.GONE else View.VISIBLE
//    }
//
//    fun bottomContainerInvalidVis(): Int {
//        return if (ifEdit.value == true && fullCount > 0) View.VISIBLE else View.GONE
//    }
//
//    fun cashVis(): Int {
//        return if (tabIndex.value != 1 && ifEdit.value != true) View.VISIBLE else View.GONE
//    }
//
//    fun formatCashBtn(): String = "去结算(${skuNumber.value})"
//
//    fun formatOriginalPrice(): String = (originalPrice.value ?: 0.0).formatCNYPrice()
//    fun formatDisAmountInDialog(): String = (disAmount.value ?: 0.0).formatCNYPrice()
//
//    fun priceInt(): String {
//        return totalPrice.value?.toInt()?.toString() ?: "0"
//    }
//
//    fun priceFloat(): String {
//        val ps = totalPrice.value?.formatDecimal(2) ?: "0.00"
//        return ".${ps.split(".").last()}".replace(".00", "")
//    }
//
//    fun formatDisAmount(): String {
//        val disVal = disAmount.value ?: 0.0
//        return if (disVal > 0) {
//            "预计减${disVal.formatCNYPrice()}"
//        } else {
//            ""
//        }
//    }
//
//    fun formatDelCount(): String {
//        return if (checkedCount.value!! > 0) "删除(${checkedCount.value})" else "删除"
//    }
//
//    fun formatFollowCount(): String {
//        return if (checkedCount.value!! > 0) "关注(${checkedCount.value})" else "关注"
//    }
//
//    fun formatFavoriteBtn(): String {
//        // return if (checkedCount.value!! > 0) "移入收藏(${checkedCount.value})" else "移入收藏"
//        return "移入收藏"
//    }
//
//    fun formatCheckAllCount(): String {
//        return "全选"
//        // return if (checkedCount.value!! > 0) "全选(${checkedCount.value})" else "全选"
//    }
//
//    fun hasCheckAll(): Boolean {
//        return checkedCount.value!! > 0 && checkedCount.value == totalCount.value
//    }
//
//    fun release() {
//        ifEdit.value = false
////        totalCount.value = 0
////        checkedCount.value = 0
//    }
//}
//
//class OrderResultState(
//    var ifDou: Boolean = false,
//    var ifSuccess: Boolean = false,
//    var orderId: Long = 0,
//    var orderCode: String = "",
//    var dou: Int = 0
//) {
//    fun mock(): OrderResultState {
//        ifSuccess = Random.nextBoolean()
//        orderId = Random.nextLong(1, Long.MAX_VALUE)
//        orderCode = UUID.randomUUID().toString()
//        dou = Random.nextInt(40, 200)
//
//        return this
//    }
//
//    fun douTipsVis(): Int {
//        // 支付成功后，取消龙豆展示，放到订单详情里面了
//        return View.GONE
//        // return if (ifSuccess && !ifDou) View.VISIBLE else View.INVISIBLE
//    }
//
//    fun stateName(): String {
//        return if (ifDou) {
//            if (ifSuccess) "兑换成功" else "兑换失败"
//        } else {
//            if (ifSuccess) "支付成功" else "支付失败"
//        }
//    }
//
//    fun specialBtnTxt(): String {
//        return if (ifDou) "继续兑换" else "继续购物"
//    }
//
//    fun stateIcon() = if (ifSuccess) R.mipmap.icon_state_pay_success else R.mipmap.icon_state_pay_failed
//
//    fun formatDouTips(): String {
//        return "恭喜您获得${dou}个龙豆"
//    }
//}
//
//class OrderResultRow(
//    var id: Long = 0,
//    var type: Int = OrderResultMultiAdapter.GOODS_START,
//    var state: OrderResultState? = null,
//    var goods: MallGoods? = null
//) : MultiItemEntity {
//    override val itemType: Int
//        get() = type
//
//    fun ifDou(): Boolean = state?.ifDou ?: false
//
//    fun getSpanSize(): Int {
//        return when (type) {
//            OrderResultMultiAdapter.GOODS_START, OrderResultMultiAdapter.GOODS_END -> 1
//            else -> 2
//        }
//    }
//}
//
//object HomeConfCode {
//    const val SKILL = "skill"
//    const val HOT_ACTIVITY = "hotActivity"
//}
//
//data class MallHomeConfItem(
//    val id: Long = 0,
//    val code: String?,
//    val isShow: Boolean = false,
//    val name: String?
//)
//
//data class CreateOrderDTO(
//    val orderCode: String? = null,// 订单code
//    val surplusPayTime: Long? = null,// 剩余可支付时间(时间戳)
//    val originalPrice: Double? = null,// 订单原价
//    val discountPrice: Double? = null,// 订单优惠
//    val accountBalance: Double? = null,// 账户余额
//    val amountPaid: Double? = null,// 本次订单应付金额
//    val balanceDue: Double? = null,// 订单结欠金额
//    val profitPrice: Double? = null,// 手续费金额
//    val errorMsg: String? = null
//)
//
//data class OrderStateItem(
//    var status: String? = null,
//    var statusDesc: String? = null,
//    val sort: Int = 0
//) {
//    fun makeAll(): OrderStateItem {
//        status = MallOrderState.ALL
//        statusDesc = MallOrderState.STATE_NAMES[MallOrderState.ALL]
//        return this
//    }
//
//    fun makeByState(state: String): OrderStateItem {
//        status = state
//        statusDesc = MallOrderState.STATE_NAMES[state]
//        return this
//    }
//}
//
//data class OrderEvaluationItem(
//    val star: Float = 0f,// 打分数
//    val content: String? = null,// 评价描述
//    val goodsSkuCode: String? = null,// 商品规格编码
//    val orderDetailCode: String? = null,// 订单详情编码
//    val vouchers: List<Long>? = null,// 上传凭证
//)